<?php

/**
 *  Ini adalah project open source yang dikembangkan oleh Impossible Team
 *
 *  Copyright (c) 2011 ekoindri. <ekoindri@ekoindri.com>
 *
 *  Versi: 1.2
 *  Developed by: Impossible Team
 *  Leader: Eko Indriyawan
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 *  USA
 *
 */

require_once("rpcl/rpcl.inc.php");
require_once("soap_sis_common.php");
require_once("soap_sis_common_input.php");
require_once("soap_sis_common_combo.php");
  //Includes
use_unit("webservices.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

function DATA_MAPEL(
$connection_string){
  mysql_connect($connection_string[server_host], $connection_string[server_username], $connection_string[server_password]);
  mysql_select_db($connection_string[server_database]) or die(mysql_error());

  $sql = "
          SELECT    ID,
                    MAPEL_KODE,
                    MAPEL_NAMA,
                    MAPEL_JENIS,
                    MAPEL_KELAS
          FROM      TABEL_MAPEL
          ORDER BY  MAPEL_NAMA ASC
          ";
  $result = mysql_query($sql);

  $numrows = mysql_num_rows($result);
  $mapellist = array();
  for($x = 0; $x < $numrows; $x++){
    $mapellist[] = mysql_fetch_array($result);
    }

  mysql_close();
  return array('Berhasil', $mapellist);
  }

function SISWA_SIMPAN_MAPELSOAL_DATASET($connection_string, $daftarmapelsoal){

  mysql_connect($connection_string[server_host], $connection_string[server_username], $connection_string[server_password]);
  mysql_select_db($connection_string[server_database]) or die(mysql_error());

  for($x = 0; $x < 100; $x++){
    $mapelsoal = $daftarmapelsoal[$x];
    if($mapelsoal[MAPEL_ID] != '') {

      $query = "
            INSERT INTO TABEL_MAPEL_SOAL
            (
            MAPEL_ID,
            MAPELSOAL_KODE,
            MAPELSOAL_JENIS,
            MAPELSOAL_KELAS,
            MAPELSOAL_WAKTU,
            MAPELSOAL_PERTANYAAN,
            MAPELSOAL_JAWABAN,
            MAPELSOAL_PILIHAN_A,
            MAPELSOAL_PILIHAN_B,
            MAPELSOAL_PILIHAN_C,
            MAPELSOAL_PILIHAN_D,
            MAPELSOAL_PILIHAN_E,
            MAPELSOAL_URL_GAMBAR,
            MAPELSOAL_KETERANGAN
            )
            VALUES
            (
            '" . $mapelsoal[MAPEL_ID] . "',
            '" . $mapelsoal[MAPELSOAL_KODE] . "',
            '" . $mapelsoal[MAPELSOAL_JENIS] . "',
            '" . $mapelsoal[MAPELSOAL_KELAS] . "',
            '" . $mapelsoal[MAPELSOAL_WAKTU] . "',
            '" . $mapelsoal[MAPELSOAL_PERTANYAAN] . "',
            '" . $mapelsoal[MAPELSOAL_JAWABAN] . "',
            '" . $mapelsoal[MAPELSOAL_PILIHAN_A] . "',
            '" . $mapelsoal[MAPELSOAL_PILIHAN_B] . "',
            '" . $mapelsoal[MAPELSOAL_PILIHAN_C] . "',
            '" . $mapelsoal[MAPELSOAL_PILIHAN_D] . "',
            '" . $mapelsoal[MAPELSOAL_PILIHAN_E] . "',
            '" . $mapelsoal[MAPELSOAL_URL_GAMBAR] . "',
            '" . $mapelsoal[MAPELSOAL_KETERANGAN] . "'
            )
            ";

      $result = mysql_query($query);

      }
    }
  }

  //Class definition
class DM_ENTRY_SISWA_MAPELSOAL extends DataModule{
  public $SIS_ENTRY_SISWA_MAPELSOAL = null;
  function SIS_ENTRY_SISWA_MAPELSOALAddComplexTypes($sender, $params){
    RegisterCommonComplexType_InfoServer($this->$SIS_ENTRY_SISWA_MAPELSOAL);
    RegisterCommonComplexType_DataMapel_Combo($this->$SIS_ENTRY_SISWA_MAPELSOAL);
    RegisterCommonComplexType_DataMapelSoalInput($this->$SIS_ENTRY_SISWA_MAPELSOAL);
    }

  function SIS_ENTRY_SISWA_MAPELSOALRegisterServices($sender, $params){

    $this->$SIS_ENTRY_SISWA_MAPELSOAL->register(
    "DATA_MAPEL",
    array(
          'connection_string'=>'tns:TInfoServer'),
    array('return'=>'xsd:string',
          'mapellist'=>'tns:TDataMapel')
    );

    $this->$SIS_ENTRY_SISWA_MAPELSOAL->register
    (
    "SISWA_SIMPAN_MAPELSOAL_DATASET",
    array(
          'connection_string'=>'tns:TInfoServer',
          'daftarmapelsoal'=>'tns:TDataMapelSoalInput'),
    array('return'=>'xsd:string'),
    'http://localhost/'
    );

    }
  }

global $application;

global $DM_ENTRY_SISWA_MAPELSOAL;

  //Creates the form
$DM_ENTRY_SISWA_MAPELSOAL = new DM_ENTRY_SISWA_MAPELSOAL($application);

  //Read from resource file
$DM_ENTRY_SISWA_MAPELSOAL->loadResource(__FILE__);

?>